      logical ldv
 
c      integer n,ifail,minpts,maxpts,iwk,nfnevl,nfuncs_
      integer n,ifail,minpts,maxpts,iwk,nfnevl
      real*8 a(*),b_adapt(*),wk(nfuncs_,*)
      real*8 ctr(15),wth(15),wthl(15),z(15)
      real*8 w(2:15,5),wp(2:15,3)

      real*8 f_return(nfuncs_)

      real*8 eps,relerr,result(*)
      integer ifncls,irgnst,irlcls,isbrgn,isbrgs,j_adapt,idvaxn,idvax0,
     &     j1,k_adapt,l,m_adapt,isbtmp,isbtpp,nfuncs_count,mef
      real*8 r1,hf,xl2,xl4,xl5,w2,w4,wp2,wp4,abserr(nfuncs_),twondm,
     &     rgnvol,sum1(nfuncs_),sum2(nfuncs_),sum3(nfuncs_),
     &     sum4(nfuncs_),sum5(nfuncs_),dif,difmax,f2(nfuncs_),
     &     f3(nfuncs_),rgncmp(nfuncs_),rgnval(nfuncs_),rgnerr(nfuncs_)


      parameter (n = 2)
      parameter (r1 = 1, hf = r1/2)
 
      parameter (xl2 =  0.35856 85828 00318 073d0)
      parameter (xl4 =  0.94868 32980 50513 796d0)
      parameter (xl5 =  0.68824 72016 11685 289d0)
 
      parameter (w2 =  980*r1/6561, w4 = 200*r1/19683)
      parameter (wp2 =  245*r1/486, wp4 = 25*r1/729)
 
      data (w(j_adapt,1),w(j_adapt,3),j_adapt=2,15)
     1/-0.193872885230909911d+00,  0.518213686937966768d-01,
     2 -0.555606360818980835d+00,  0.314992633236803330d-01,
     3 -0.876695625666819078d+00,  0.111771579535639891d-01,
     4 -0.115714067977442459d+01, -0.914494741655235473d-02,
     5 -0.139694152314179743d+01, -0.294670527866686986d-01,
     6 -0.159609815576893754d+01, -0.497891581567850424d-01,
     7 -0.175461057765584494d+01, -0.701112635269013768d-01,
     8 -0.187247878880251983d+01, -0.904333688970177241d-01,
     9 -0.194970278920896201d+01, -0.110755474267134071d+00,
     a -0.198628257887517146d+01, -0.131077579637250419d+00,
     b -0.198221815780114818d+01, -0.151399685007366752d+00,
     c -0.193750952598689219d+01, -0.171721790377483099d+00,
     d -0.185215668343240347d+01, -0.192043895747599447d+00,
     e -0.172615963013768225d+01, -0.212366001117715794d+00/
 
      data (w(j_adapt,5),w(j_adapt+1,5),j_adapt=2,14,2)
     1/ 0.871183254585174982d-01,  0.435591627292587508d-01,
     2  0.217795813646293754d-01,  0.108897906823146873d-01,
     3  0.544489534115734364d-02,  0.272244767057867193d-02,
     4  0.136122383528933596d-02,  0.680611917644667955d-03,
     5  0.340305958822333977d-03,  0.170152979411166995d-03,
     6  0.850764897055834977d-04,  0.425382448527917472d-04,
     7  0.212691224263958736d-04,  0.106345612131979372d-04/
 
      data (wp(j_adapt,1),wp(j_adapt,3),j_adapt=2,15)
     1/-0.133196159122085045d+01,  0.445816186556927292d-01,
     2 -0.229218106995884763d+01, -0.240054869684499309d-01,
     3 -0.311522633744855959d+01, -0.925925925925925875d-01,
     4 -0.380109739368998611d+01, -0.161179698216735251d+00,
     5 -0.434979423868312742d+01, -0.229766803840877915d+00,
     6 -0.476131687242798352d+01, -0.298353909465020564d+00,
     7 -0.503566529492455417d+01, -0.366941015089163228d+00,
     8 -0.517283950617283939d+01, -0.435528120713305891d+00,
     9 -0.517283950617283939d+01, -0.504115226337448555d+00,
     a -0.503566529492455417d+01, -0.572702331961591218d+00,
     b -0.476131687242798352d+01, -0.641289437585733882d+00,
     c -0.434979423868312742d+01, -0.709876543209876532d+00,
     d -0.380109739368998611d+01, -0.778463648834019195d+00,
     e -0.311522633744855959d+01, -0.847050754458161859d+00/

